package datatypes.r2.foundation.impl;

import javax.persistence.Column;
import javax.persistence.Embeddable;

import datatypes.r2.flavors.ST_SIMPLE;
import datatypes.r2.foundation.BL;

/**
 * A binary value for use in boolean logic. A BL value can be either true or
 * false, or, as any other value, MAY be NULL.
 * 
 * @author Obama
 */
@Embeddable
public class Boolean extends DataValue implements BL {

	private static final long serialVersionUID = 1L;

	/**
	 * The opposite value. Negation of a BL turns true into false and false into
	 * true and is NULL for NULL values.
	 */

	private Boolean not;

	@Column(name = "boolean_value")
	private java.lang.Boolean value;

	public Boolean or(Boolean x) {
		return new Boolean(x.getValue() | value);
	}

	public Boolean xor(Boolean x) {
		return null;
	}

	public Boolean implies(Boolean x) {
		return null;
	}

	public Boolean(java.lang.Boolean value) {
		super();
		this.value = value;
		if (value != null) {
			this.not = new Boolean(!value);
		} else {
			this.not = new Boolean(null);
		}
	}

	public Boolean() {
		super();
		this.not = new Boolean(null);
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public java.lang.Boolean getValue() {
		return value;
	}

	public void setValue(java.lang.Boolean value) {
		this.value = value;
		if (value != null) {
			this.not = new Boolean(!value);
		} else {
			this.not = new Boolean(null);
		}
	}

	@Override
	public BL not() {
		return not;
	}

	@Override
	public BL and(BL x) {
		// if (x == null) {
		// throw new NullPointerException("Boolean cannot be null!");
		// }
		// if (value != null && x.literal() != null) {
		// return new Boolean(value & x.literal());
		// } else if (value == null && x.literal() == null) {
		// return new Boolean(null);
		// } else if (value == null) {
		// if (x.getValue() == false) {
		// return new Boolean(false);
		// } else {
		// return new Boolean(null);
		// }
		// } else {
		// if (value == false) {
		// return new Boolean(false);
		// } else {
		// return new Boolean(null);
		// }
		// }
		return null;
	}

	@Override
	public BL or(BL x) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public BL xor(BL x) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public BL implies(BL x) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ST_SIMPLE literal() {
		// TODO Auto-generated method stub
		return null;
	}
	
	

}
